$(function() {
	baseURL = /apistore/
	var vm = new Vue({
		el : '#basicDiv',
		data : {
			showDiv1 : true,
			showDiv2 : true,
			showDiv3 : true,
			showDiv4 : true,
			showDiv5 : true,
			error : false,
			errorMsg : '',
			num : '',
			interfaceUrl:"",//接口地址
			returnFormat:"",//返回格式
			requestType:"",//请求方式
			requestExamples:"",//请求示例
			interfaceRemark:"",//接口备注
			requestExamples:"",//请求示例
			returnExamples:"",//返回示例
			parameters:[],//接口参数
			serviceErrorCode:[],//错误码
			serviceExamples:[],//示例代码
			QQ:"",//qq
			WeChart:"",//微信
			phoneNum:""//电话
		},
		methods : {
			tabFun : function() {
				vm.showDiv = true
				if (event) {
					// alert(event.target.tagName)
					var num = parseInt(event.target.getAttribute("num"), 0)
					debugger
					switch (num) {
					case 1:
						vm.showDiv1 = true
						vm.showDiv2 = true
						vm.showDiv3 = true
						vm.showDiv4 = true
						vm.showDiv5 = true
						this.tab1();
						break;
					case 2:
						vm.showDiv1 = false
						vm.showDiv2 = false
						vm.showDiv3 = true
						vm.showDiv4 = true
						vm.showDiv5 = true
						this.tab2()
						break;
					case 3:
						vm.showDiv1 = false
						vm.showDiv2 = true
						vm.showDiv3 = false
						vm.showDiv4 = true
						vm.showDiv5 = true
						this.tab3()
						break;
					case 4:
						vm.showDiv1 = false
						vm.showDiv2 = true
						vm.showDiv3 = true
						vm.showDiv4 = false
						vm.showDiv5 = true
						this.tab4()
						break;
					case 5:
						vm.showDiv1 = false
						vm.showDiv2 = true
						vm.showDiv3 = true
						vm.showDiv4 = true
						vm.showDiv5 = false
						this.tab5()
						break;
					default:
						break;
					}
				}
			},
			tab1:function(){
				$.get(baseURL + "loadApiDetail/"+serviceCode+"/tab1", function(r) {
					if(r.serviceHeader!=null){
						var serviceHeader=r.serviceHeader
						
						var img=serviceHeader.serviceImage //图片
						var serviceName=serviceHeader.serviceName//服务名
						var serviceType=serviceHeader.categoryCode//服务类别
						var shortDesc=serviceHeader.shortDesc//描述
						var releaseName=serviceHeader.releaseName//描述
						
						var serviceFunction=serviceHeader.serviceFunction//产品功能
						var serviceIntroduce=serviceFunction.serviceIntroduce//功能介绍
						var serviceExamples=serviceFunction.serviceExamples//功能实例
						
						//添加图片
						$("#apiImg").css({
							"background":"url(localImg/"+img+") no-repeat",
							"background-size": "contain",
							"background-position": "center center"
						})


						//申请按钮赋值
						$("#requestApi").attr("categoryCode",serviceHeader.categoryCode)
						$("#requestApi").attr("serviceCode",serviceCode)
						$("#serviceName").text(serviceName)
						$("#shortDesc").text(shortDesc)
						$("#usedCount").text(20)
						var serviceIntroduce=serviceIntroduce.split("||")
						
						$("#funDesc").text("")
						var ul=$("<ul></ul>")
						for(var i=0;i<serviceIntroduce.length;i++){
							ul.append($("<li></li>").append(serviceIntroduce[i]))
						}
						$("#funDesc").append(ul)
						debugger
						$("#funExample").css({
							"background":"url(localImg/"+serviceExamples+") no-repeat",
							"background-size": "contain"
						})
					}
				});
			},
			tab2:function(){
				$.get(baseURL + "loadApiDetail/"+serviceCode+"/tab2", function(r) {
					if(r.serviceHeader.serviceApi!=null){
						vm.interfaceUrl=r.serviceHeader.serviceApi.interfaceUrl//接口地址
						vm.returnFormat=r.serviceHeader.serviceApi.returnFormat//返回格式
						vm.requestType=r.serviceHeader.serviceApi.requestType//请求方式
						vm.requestExamples=r.serviceHeader.serviceApi.requestExamples//请求示例
						vm.interfaceRemark=r.serviceHeader.serviceApi.interfaceRemark//接口备注
						vm.requestExamples=r.serviceHeader.serviceApi.requestExamples//请求示例
						vm.returnExamples=r.serviceHeader.serviceApi.returnExamples//返回示例
					}
					debugger
					
					vm.parameters=r.serviceHeader.serviceParameter
					
					//paramName//参数类型
					//isMust//是否必须
					//dataType//参数类型
					//remark//说明
					
				});
			},tab3:function(){
				$.get(baseURL + "loadApiDetail/"+serviceCode+"/tab3", function(r) {
					debugger
					if(r.serviceHeader.serviceErrorCode!=null){
						vm.serviceErrorCode=r.serviceHeader.serviceErrorCode
					}
				});
				
			},tab4:function(){
				$.get(baseURL + "loadApiDetail/"+serviceCode+"/tab4", function(r) {
					vm.serviceExamples=r.serviceHeader.serviceExamples
					debugger
					
				});
				
			},tab5:function(){
				$.get(baseURL + "loadApiDetail/"+serviceCode+"/tab5", function(r) {
					debugger
					vm.QQ=r.serviceHeader.serviceQq//qq
					vm.WeChart=r.serviceHeader.serviceWechat//微信
					vm.phoneNum=r.serviceHeader.contactNumber//电话
				});
				
			}
		},
		mounted : function() {
			this.tab1()
		}
	});
})

//点击申请跳转事件
$(document).on("click","#requestApi",function(e){
	//弹出框判断是否登陆
	//登陆跳转后台申请页面
	//未登陆跳转登陆页面
	var categoryCode = $(this).attr("categoryCode");
	var serviceCode = $(this).attr("serviceCode");
	window.location.href=baseURL +"userApply?categoryCode="+categoryCode+"&serviceCode="+serviceCode;
	//window.location.href="/apistore/#userApply"
});